package com.yonyou.iuap.ipaas.connector.sdwcoatencent.internal.exception;

import com.yonyou.iuap.ipaas.connector.sdk.exception.CommonErrorTypeDefinition;
import com.yonyou.yonlinker.ysb.runtime.extension.api.error.ErrorTypeDefinition;
import com.yonyou.yonlinker.ysb.runtime.extension.api.exception.YsbModuleException;

public class ExecuteException extends YsbModuleException {

    public <T extends Enum<T>> ExecuteException(String message, ErrorTypeDefinition<T> errorTypeDefinition, Throwable cause) {
        super(message, errorTypeDefinition, cause, "500", null);
    }

    public static ExecuteException connectivityError(String message) {
        return new ExecuteException(message, CommonErrorTypeDefinition.CONNECTIVITY, null);
    }

    public static ExecuteException connectivityError(String message, Throwable cause) {
        return new ExecuteException(message, CommonErrorTypeDefinition.SERVER_RESPONSE_ERROR, cause);
    }

    public static ExecuteException serverRequestError(String message) {
        return new ExecuteException(message, CommonErrorTypeDefinition.SERVER_REQUEST_ERROR, null);
    }

    public static ExecuteException serverRequestError(String message, Throwable cause) {
        return new ExecuteException(message, CommonErrorTypeDefinition.SERVER_REQUEST_ERROR, cause);
    }

    public static ExecuteException serverResponseError(String message) {
        return new ExecuteException(message, CommonErrorTypeDefinition.SERVER_RESPONSE_ERROR, null);
    }

    public static ExecuteException serverResponseError(String message, Throwable cause) {
        return new ExecuteException(message, CommonErrorTypeDefinition.SERVER_RESPONSE_ERROR, cause);
    }
}
